package com.zh.common.ktx

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class AdapterKtx {
}

fun <Entity> bindAdapter(
    layoutId: Int,
    callBack: (holder: BaseViewHolder, item: Entity) -> Unit
): BaseQuickAdapter<Entity, BaseViewHolder> {
    return object : BaseQuickAdapter<Entity, BaseViewHolder>(layoutId) {
        override fun convert(holder: BaseViewHolder, item: Entity) {
            callBack.invoke(holder, item)
        }
    }
}

fun <Entity> bindAdapter(
    layoutId: Int,
    callBack: (holder: BaseViewHolder, item: Entity, data: List<Entity>) -> Unit
): BaseQuickAdapter<Entity, BaseViewHolder> {

    return object : BaseQuickAdapter<Entity, BaseViewHolder>(layoutId) {
        override fun convert(holder: BaseViewHolder, item: Entity) {
            callBack.invoke(holder, item, data)
        }
    }
}